package com.wz.common.business;


import com.github.pagehelper.PageHelper;
import com.wz.common.bean.PageBean;
import com.wz.common.bean.PageMap;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * <p>Project: wz_api -BaseServiceImpl
 * <p>Powered by pisces On 2022-01-13 16:24:25
 * <P>Created by IntelliJ IDEA
 *
 * @author ww606851@163.com
 * @version 1.0
 * @description:
 * @since 8
 */

public class BaseServiceImpl<T, D extends IDao> implements IService<T> {

	@Autowired(required = false)
	D baseDao;

	@Override
	public int save(T t) {
		return baseDao.save(t);
	}

	@Override
	public int update(T t) {
		return baseDao.update(t);
	}

	@Override
	public int delete(Serializable id) {
		return baseDao.delete(id);
	}

	@Override
	public T getById(Serializable id) {
		return (T) baseDao.getById(id);
	}

	@Override
	public PageBean query(Map map) {
		PageMap pageMap = new PageMap(map);
		PageHelper.startPage(pageMap.getPageNum(), pageMap.getPageSize());
		List list = baseDao.query();
		return new PageBean(list);
	}
}
